using RimWorld;
using Verse;
using Verse.Sound;

namespace RimZombieGirl
{
    public class CompAbilityEffect_CostBlood : CompAbilityEffect
    {
        public new CompProperties_CostBlood Props => (CompProperties_CostBlood)props;

        private Pawn casterPawn => this.parent.pawn;

        public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
        {
            base.Apply(target, dest);
            Pawn pawn = target.Pawn;
            if (pawn == null)
            {
                return;
            }
            // 预留血液相关逻辑
            ApplyCostBloodEffect(casterPawn, Props.amount);

        }

        // 空白方法，用户可自行实现血液相关逻辑
        public void ApplyCostBloodEffect(Pawn caster, int bloodAmount)
        {
            var deadGene = caster.GetZombieGene();
            if (deadGene != null)
            {
                deadGene.BloodCurrent -= bloodAmount;
            }
        }

        public override bool GizmoDisabled(out string reason)
        {
            reason = null;
            // 禁用Gizmo当血量不足  
            var deadGene = casterPawn.GetZombieGene();
            if (deadGene != null && deadGene.BloodCurrent < Props.amount)
            {
                reason = "Not enough blood".Translate();
                return true;
            }
            return false;
        }
    }
}
